package edu.java.homework.hw05;

/**
 * factoriel --> recursive and iterative realization
 * 
 * @author Tsvetan Vasilev
 * 
 */
public class Exercise01done {

    public static void main(String[] args) {
	// iterative realization
	int number = 10;
	System.out.println("Iterative realization:\n" + number + "!= "
		+ factIter(number));
	
	System.out.println("Recursive realization:\n" + number + "!= "
		+ factRec(number));
	

    }

    public static int factIter(int number) {
	int result = 1;
	if (number == 0) {
	    return result;
	}
	for (int i = 1; i <= number; i++) {
	    result *= i;
	}
	return result;
    }
    
    public static int factRec(int number){
	if(number==0){
	    return 1;
	}else{
	    return number* factRec(number-1);
	}
    }

}
